package org.jeecg.modules.demo.crm.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.demo.crm.entity.CEmail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Description: 邮件
 * @Author: jeecg-boot
 * @Date:   2025-07-04
 * @Version: V1.0
 */
public interface CEmailMapper extends BaseMapper<CEmail> {


    @Select("select * from c_email where status='待发送'")
    List<CEmail> taskEMail();

    /**
     * 查询某条数据是否存在 避免重复发送 1天内
     * @param dataKey
     * @return
     */
    @Select("select * from c_email where data_key=#{dataKey}  AND create_time >= NOW() - INTERVAL 1 DAY")
    CEmail findByDataKey(@Param("dataKey") String dataKey);
}
